<template>
    <div>
      <div style="display: inline-flex; margin-top: 20px">
        <el-input
          v-model="name"
          :disabled="disabled"
          :placeholder="placeholder"
          prefix-icon="el-icon-search"
          style="width: 350px; margin-right: 10px"
          clearable
          @clear="search"
          @keydown.enter.native="search"
        ></el-input>
  
        <el-button
          :disabled="disabled"
          icon="el-icon-search"
          type="primary"
          @click="search"
        >
          搜索
        </el-button>
      </div>
  
      
  
     
  
      <!--表单部分-->
  
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column fixed prop="id" label="id" width="150">
        </el-table-column>
  
        <el-table-column prop="problemtitle" label="问题标题" width="220">
        </el-table-column>
  
        <el-table-column prop="problemtext" label="问题内容" width="320">
        </el-table-column>
  
        <el-table-column prop="createtime" label="创建时间" width="320">
        </el-table-column>
  
        <el-table-column prop="userId" label="用户" width="120">
        </el-table-column>
  
        <el-table-column fixed="right" label="操作" width="100">
          <template slot-scope="scope">
            <el-tooltip class="item" effect="dark" content="删除" placement="top">
              <el-button
                type="danger"
                icon="el-icon-delete"
                circle
                @click="deleteVisible(scope.$index)"
              ></el-button>
            </el-tooltip>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </template>
  
  
  
  <script>
  export default {
    name: "Charge",
  
    methods: {
      //模糊查询
  
      search() {
        this.axios
          .get(
            "/consultproblem/findlike",
  
            {
              params: {
                name: this.name,
              },
            }
          )
  
          .then((resp) => {
            console.log(resp);
  
            const r = resp.data;
  
            this.tableData = r.data;
  
            // setTimeout(()=>{this.refresh()},500)
          });
      },
  
      //上传相关的
  
      handleRemove(file) {
        console.log(file);
      },
  
      handlePictureCardPreview(file) {
        this.dialogImageUrl = file.url;
  
        this.dialogVisible = true;
      },
  
      handleDownload(file) {
        console.log(file);
      },
  
      uploadImg(resp) {
        console.log(resp.data);
  
        this.form.image = r.data;
      },
  
      handleClick(row) {
        console.log(row);
      },
  
    //   add() {
    //     this.axios
    //       .post("/charge/add", {
  
    //         id: this.form.id,
    //         chargetype: this.form.chargeType,
  
    //         chargeprice: this.form.chargePrice,
  
    //         countnumber: this.form.countNumber,
  
    //         teacherId: this.form.teacherId,
    //       })
    //       .then((resp) => {
    //         const r = resp.data;
  
    //         console.log(r);
  
    //         // this.$message.success("添加成功");
    //       });
  
    //     //关闭
  
    //     this.dialogFormVisible = false;
    //   },
  
    //   update() {
    //     this.axios
    //       .put("/charge/updata", null, {
    //         params: {
    //         id: this.form.id,
    //         chargetype: this.form.chargeType,
  
    //         chargeprice: this.form.chargePrice,
  
    //         countnumber: this.form.countNumber,
  
    //         teacherId: this.form.teacherId,
    //         },
    //       })
    //       .then((resp) => {
    //         const r = resp.data;
  
    //         console.log(r);
  
    //         this.$message.success("修改成功");
    //       });
  
    //     //关闭
  
    //     this.dialogFormVisible2 = false;
    //   },
  
      //删除
  
      deleteVisible(index) {
        this.form.id = this.tableData[index].id;
  
        //提交请求
  
        this.axios
          .delete("/consultproblem/delete", {
            params: {
              id: this.form.id,
            },
          })
          .then((resp) => {
            const r = resp.data;
  
            console.log(r);
  
            this.$message.success("删除成功!");
  
            setTimeout(() => {
              this.refresh();
            }, 500);
          });
  
        // location.reload();
      },
  
      //
  
      refresh() {
        this.axios
          .get("/consultproblem/find")
  
          .then((resp) => {
            const r = resp.data;
  
            this.tableData = r.data;
          });
      },
    },
  
    data() {
      return {
        dialogImageUrl: "",
  
        dialogVisible: false,
  
        disabled: false,
  
        dialogFormVisible2: false,
  
        dialogFormVisible: false,
  
        form: {
          id: "",
  
          problemTitle: "",
  
          problemText: "",
  
          createTime: "",
  
          userId: "",
        },
  
        name: "",
  
        // consult:{
  
        //     Startdate: new Data(),
  
        // },
  
        tableData: [
          {
            id: "",
  
          problemTitle: "",
  
          problemText: "",
  
          createTime: "",
  
          userId: "",
          },
        ],
  
        formLabelWidth: "120px",
      };
    },
  
    created() {
      this.refresh();
    },
  };
  </script>
  
  
  